package com.qf.week2.homework;

import java.util.Scanner;

public class Menu {

    public static void main(String[] args) {

    }

    public void show() {
        BookInterface bookInterface = new BookInterfaceImpl();
        while (true) {
            System.out.println("请选择功能：1.增加 \t 2.查询 \t 3. 删除 \t 4.更新 \t 5.打印全部 \t");
            Scanner scanner = new Scanner(System.in);
            String menuItem = scanner.next();
            switch (menuItem) {
                case "1":
                    System.out.println("请输入增加的图书名字");
                    String bookName = scanner.next();
                    System.out.println("请输入增加的图书总页数：");
                    String bookPage = scanner.next();
                    Book book = new Book(bookName, bookPage);
                    boolean flag = bookInterface.addBook(book);
                    if (flag) {
                        System.out.println("successful");
                    } else {
                        System.out.println("failed");
                    }
                    break;
                case "2":
                    System.out.println("请输入图书名字:");
                    String selectName = scanner.next();
                    bookInterface.selectOne(selectName);

                    break;
                case "3":
                    System.out.println("请输入要删除的图书名字：");
                    String delName = scanner.next();
                    bookInterface.deleteBook(delName);
                    break;

                case "4":
                    System.out.println("请输入更新图书名字：");
                    String upName = scanner.next();
                    System.out.println("请您输入更新图书的总页数");
                    String upPage = scanner.next();
                    Book book1 = new Book(upName, upPage);
                    boolean updated = bookInterface.updateBook(book1);

                case "5":
                    bookInterface.selectAll();
                    break;

                default:
                    System.out.println("输入错误");

            }
        }

    }
}
